package com.nh.action;

import org.hibernate.Criteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

import com.nh.entity.GKLBookType;

public class GKLBookTypeAction extends BaseAction {
	private GKLBookType classType;
	private Long optionId;
	private int columnTag;
	private Long classTypeId;

	public String classTypeList() {
		Criteria criteria = this.createCriteria(GKLBookType.class);
		criteria.add(Restrictions.eq("classTypeId", classTypeId));
		// criteria.addOrder(Order.desc("publishTime"));
		criteria.addOrder(Order.asc("typeOrder"));
		this.queryByPage(criteria, "gKLBookTypeAction!classTypeList.action", 10);
		return "classTypeList";
	}

	public String addClassType() {
		classType = new GKLBookType();
		return "addClassType";
	}

	public String saveClassType() {
		classType.setClassTypeId(classTypeId);
		if (null == classType.getId()) {
			// product.setCreateTime(new Timestamp(System.currentTimeMillis()));
				
			this.getBaseService().save(classType);
		} else {
			// user.setCreateTime(new Timestamp(System.currentTimeMillis()));
			this.getBaseService().saveOrUpdate(classType, GKLBookType.class);
		}
		return classTypeList();
	}

	public String modifyClassType() {
		classType = this.getBaseService().findById(optionId, GKLBookType.class);
		return "addClassType";
	}

	public String removeClassType() {
		this.getBaseService().delete(optionId, GKLBookType.class);
		return classTypeList();
	}

	public GKLBookType getClassType() {
		return classType;
	}

	public void setClassType(GKLBookType classType) {
		this.classType = classType;
	}

	public Long getOptionId() {
		return optionId;
	}

	public void setOptionId(Long optionId) {
		this.optionId = optionId;
	}

	public int getColumnTag() {
		return columnTag;
	}

	public void setColumnTag(int columnTag) {
		this.columnTag = columnTag;
	}

	public String getInfoTitle() {
		String temp = "";
		switch (columnTag) {
		case 0:
			temp = "公司简介";
			break;
		case 1:
			temp = "旅客须知";
			break;
		case 2:
			temp = "云南旅游";
			break;
		case 3:
			temp = "国内旅游";
			break;
		case 4:
			temp = "出境旅游";
			break;
		case 5:
			temp = "演出酒店";
			break;
		case 6:
			temp = "景区图片";
			break;
		default:
			break;
		}
		return temp;
	}

	public Long getClassTypeId() {
		return classTypeId;
	}

	public void setClassTypeId(Long classTypeId) {
		this.classTypeId = classTypeId;
	}
}
